import { ref } from "vue";
import { useWebsiteStore } from "@/store";
import { storeToRefs } from "pinia";

export default () => {
  const websiteStore = useWebsiteStore();

  const { searchValue } = storeToRefs(websiteStore);

  const value = ref("");

  const timer = ref(null);

  const search = (e) => {
    clearTimeout(timer.value);
    timer.value = setTimeout(() => {
      searchValue.value = e;
    }, 500);
  };
  return { searchValue, value, search };
};
